Skip to content

feat(agent): lk agent versions, secrets, dockerfile and build logs through the Public API when signed in - #1139

Open
Topherhindman wants to merge 3 commits into
topherhindman/agent-user-auth-listfrom
topherhindman/agent-user-auth-reads
Open

Topherhindman wants to merge 3 commits into
topherhindman/agent-user-auth-listfrom
topherhindman/agent-user-auth-reads

Conversation

@Topherhindman

@Topherhindman Topherhindman commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Under --user-auth, the agent reads that #1138 left on the token bridge now go through the Public API's AgentService: lk agent versions, lk agent secrets, lk agent dockerfile (and the client settings that create, deploy and private-link create read), and lk agent logs --log-type build. The bridge needs the Agent.Admin grant, so before this only a project admin could run them. Now a READ member can run every one of them except secrets, which the Public API still keeps to admins.

Stacked on #1138.

Commands

Command Under --user-auth Who
agent versions ListAgentVersions READ
agent secrets ListAgentSecrets (names only) ADMIN, refused by the Public API with the role it needs
agent dockerfile, and the settings read of create, deploy, private-link create GetAgentClientSettings READ
agent logs --log-type build GetAgent for the version, then GetAgentBuildLog READ
agent logs (runtime, the default) bridge, unchanged ADMIN, with the bridge's "needs a project admin" refusal
create, deploy, update, update-secrets, restart, rollback, promote, delete, private-link * bridge (the writes move in the next PR) ADMIN

What's in it

  • The client comes from feat(agent): lk agent list, status and config through the Public API when signed in #1138's regeneration (livekit/public-api-server@372fb27e, production v2026-12-02-2258), which has the reads and the writes. This PR has no regeneration of its own.
  • feat(public): ListAgentVersions, ListAgentSecrets, GetAgentBuildLog and GetAgentClientSettings. Each returns LiveKit's own message, decoded with protojson, as ListAgents does.
  • feat(agent): userAuthAgentAPI calls them. agentServiceError words a refusal for a role that is too low as "this command needs a project admin (…)", not "your account doesn't have access to this project".
  • fix(agent): the build log reads the agent's cloud, which replaced info in livekit/public-api-server#240.

Decisions

  • Which build log. lk has no --version flag on logs. With an API key, cloud agents streams the build log of the version that the deployment runs. Under --user-auth, lk finds that version in GetAgent by the same rule (the deployment's first region with a version, else, for production, the agent's version), then reads that version's log.
  • No region check for build logs. The Public API reads a build log by version, so under --user-auth logs --log-type build skips the "no agent deployments found" check that the runtime stream needs.
  • Truncation. When the Public API returns only the end of a log (over 1 MiB), lk prints it and then says so on stderr.
  • Placeholders. The Public API leaves out the deploy time of a version that was never deployed. lk puts back the zero time that cloud agents lists, so the table shows -- and --json matches.

Output differences vs the API-key path

  • A build log comes back once the build ends. With an API key, logs --log-type build on a build in progress streams it; under --user-auth it says "build log not found". create and deploy still stream their builds through the bridge.
  • A deployment that runs no version: "no version deployed to the canary deployment of agent CA_1" under --user-auth, cloud agents' "failed to get logs: no version deployed to deployment - map[…]" with an API key.
  • secrets lists in name order under --user-auth (the Public API sorts), in cloud agents' order with an API key.

Open questions

  • Should lk agent logs --log-type build get a --version flag? The Public API takes any version.
  • Should the secret names stay ADMIN-only in the Public API? They carry no values.

Blockers

  • pkg/public generated from livekit/public-api-server@372fb27e (production v2026-12-02-2258).

Testing

  • GOPRIVATE= go build ./..., go vet ./cmd/lk/... ./pkg/..., go test ./cmd/lk/... ./pkg/... and golangci-lint run ./cmd/lk/... ./pkg/public/... pass.
  • New testscript agent-version-secret-log-reads-with-user-auth: versions (table and --json), secrets (table and --json), dockerfile (both files) and logs --log-type build (production and --deployment staging) print the same in both modes against the same data. It also checks the truncation note, "build log not found", a deployment with no version, and that a runtime log still gets the bridge's admin refusal. The fake Public API refuses every token request, and the request log shows lk made none for the reads.
  • agent-commands-with-user-auth and agent-commands-need-admin-with-user-auth now expect secrets through AgentService, and its refusal naming the role.
  • Unit tests for the four client methods (fields, 404, truncation, a bad response), deployedVersion and agentServiceError.

Demo

Recorded on staging, not uploaded yet: ~/hosted-agents-work/demos/M2/m2-agent-reads.mp4 (write-up ~/hosted-agents-work/demos/M2/README.md). Local Public API from this stack against staging cloud-agents (staging database read-only); lk from #1140. A WRITE member runs lk agent versions, dockerfile and logs --log-type build; secret names are refused for WRITE and shown for ADMIN.

Depends on #1136 (the hints name lk agent builder).

The Public API client reads the rest of what lk's agent commands read
from AgentService: an agent's versions, the names of its secrets, the
build log of a version, and the project's client settings. Each returns
LiveKit's own message (livekit.AgentVersion, livekit.AgentSecret,
livekit.ClientSettingsResponse), as ListAgents and GetAgent do, so the
commands print what they print with an API key. A build log comes back
with whether the API cut it to its end.
…h the Public API

Under --user-auth, these commands now call the Public API's
AgentService in place of the token bridge, so a member below admin can
run the reads that their role allows:

- lk agent versions: ListAgentVersions, for a READ member.
- lk agent secrets: ListAgentSecrets, which still needs a project admin.
  The refusal now comes from AgentService and names the role.
- lk agent dockerfile, and the settings read in create, deploy and
  private-link create: GetAgentClientSettings, for a READ member.
- lk agent logs --log-type build: GetAgentBuildLog, for a READ member.
  lk has no --version flag, so it reads the build log of the version that
  the deployment runs, as cloud agents does when lk names none: it finds
  that version in GetAgent. It needs no deployment region, so it skips
  the check for one. When the API cut the log, lk says so.

A runtime log (--log-type deploy) stays on the bridge, which needs a
project admin. Output matches the API-key path: lk puts back the zero
deploy time that the Public API leaves out of a version never deployed.
public.Agent's Info is Cloud since the Public API moved it
(livekit/public-api-server#240), so the build log finds the version that
the deployment runs in Cloud. The reads script's GetAgent answers in the
new shape.
@Topherhindman
Topherhindman force-pushed the topherhindman/agent-user-auth-reads branch from 5b95c2a to 8abe4c5 Compare December 3, 2026 00:18
@Topherhindman
Topherhindman marked this pull request as ready for review December 3, 2026 00:57

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant